import React, {FC} from 'react';
import "./index.less";
import {history, useParams} from "@@/exports";
import * as API from "@/services";
import {useRequest} from "ahooks";
import NewsDetailComp from "@/pages/NewsPage/NewsDetail/NewsDetailComp";

interface NewsDetailProps {
}

const NewsDetail: FC<NewsDetailProps> = (props) => {
  const urlParams = useParams();
  const newsId = urlParams["*"];

  const detailReq = useRequest(() => API.queryFrontNews(newsId!), {
    refreshDeps: [newsId],
    ready: !!newsId,
  });

  const record = detailReq.data?.data;

  return (
    !!record && (
      <NewsDetailComp record={record}/>
    )
  );
};

export default NewsDetail;
